<template>
    <view :style="objColor">
        <!-- mine/pages/set/set.wxml -->
        <view class="set">
			<view class="set-list" @tap="goPersonalData" v-if="isToken">
			    <view>个人资料</view>
			    <view>
			        <image src="https://oos-cn.ctyunapi.cn/front-end/static/mine/images/back.png"></image>
			    </view>
			</view>

            <view class="set-list" @tap="goSafetyProtection" v-if="isToken">
			    <view>安全防护</view>
			    <view>
			        <image src="https://oos-cn.ctyunapi.cn/front-end/static/mine/images/back.png"></image>
			    </view>
			</view>


			<!-- <view class="set-list" @tap="individualization">
			    <view>隐私设置</view>
			    <view>
			        <image src="https://oos-cn.ctyunapi.cn/front-end/static/mine/images/back.png"></image>
			    </view>
			</view> -->
            <!-- <view class="set-list" @tap="payset" v-if="isToken">
                <view>个人支付设置</view>
                <view>
                    <image src="https://oos-cn.ctyunapi.cn/front-end/static/mine/images/back.png"></image>
                </view>
            </view> -->
            <!-- <view class="set-list" @tap="messagenotification">
                <view>消息通知设置</view>
                <view>
                    <image src="https://oos-cn.ctyunapi.cn/front-end/static/mine/images/back.png"></image>
                </view>
            </view> -->

            <!-- <view class="set-list" bindtap="toChangePhone">
        <view>变更手机号</view>
        <view>
            <image src="../../images/back.png"></image>
        </view>
    </view> -->
            
			
			<!-- #ifdef APP-PLUS -->
			<view class="set-list" @click="delMember" v-if="memberType != 2">
			    <view>永久注销账号</view>
				<view>
				    <image src="https://oos-cn.ctyunapi.cn/front-end/static/mine/images/back.png"></image>
				</view>
			</view>
			<!-- #endif -->
			
			<view class="set-list" @tap="versions">
				<view style="border-bottom: none">关于【{{wxAppName}}】</view>
				<view style="border-bottom: none">
					<text>{{version}}</text>
					<image src="https://oos-cn.ctyunapi.cn/front-end/static/mine/images/back.png"></image>
				</view>
			</view>
			
        </view>
        <!-- 退出登录 -->

				<!-- #ifdef H5 -->
				<template v-if="!isCdgj()">
					<view class="out" @tap="Logout" v-if="isToken">退出登录</view>
				</template>
				<!-- #endif -->

				<!-- #ifndef H5 -->
				<view class="out" @tap="Logout" v-if="isToken">退出登录</view>
				<!-- #endif -->
    </view>
</template>

<script>
'use strict';

// exports.__esModule = true; // mine/pages/set/set.ts

var https_1 = require('./../../../api/https.js');
var app = getApp();
export default {
    data() {
        return {
			version: 'v' + app.globalData.appVersion,
			wxAppName:app.globalData.wxAppName,
			isToken:false,
			switchChecked:true,
			memberType:1,
		};
    }
    /**
     * 生命周期函数--监听页面加载
     */,
    onLoad: function () {
		// for (let provinceCode in area.province_list) {
		// 	this.range[0].push(area.province_list[provinceCode])
		// 	this.provinceCodes.push(provinceCode)
		// }
	},
    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
		this.isToken = uni.getStorageSync('token')
		this.switchChecked = !uni.getStorageSync('switchChecked')
		this.memberType = uni.getStorageSync('memberType')
	},
    methods: {
		delMember(){
			uni.showModal({
				title: '您确定要永久注销账号吗？',
				content: '注销后无法恢复，请谨慎操作!',
				success: function (res) {
					if (res.confirm) {
						https_1.delMember().then(res=>{
							if(res.code == 0){
								uni.removeStorageSync('token')
								uni.showModal({
									title: '提示',
									content: '注销成功！',
									showCancel:false,
									success(){
										uni.switchTab({
											url:'/pages/my/my'
										})
									}
								})
								
							}
						})
					} else if (res.cancel) {
						console.log('用户点击取消');
					}
				}
			});
		},
		switchChange(e){
			this.switchChecked = e.detail.value
			uni.setStorageSync('switchChecked',!e.detail.value)
		},
        payset: function () {
            uni.navigateTo({
                url: '../../pages/paysets/paysets'
            });
        },

        messagenotification: function () {
            uni.navigateTo({
                url: '../../pages/messagenotification/messagenotification'
            });
        },
		individualization(){
			uni.navigateTo({
			    url: '../../pages/individualization/individualization'
			});
		},

        toChangePhone: function () {
            uni.navigateTo({
                url: '/mine/pages/changePhone/changePhone'
            });
        },

        versions: function () {
            uni.navigateTo({
                url: '../../pages/versions/versions'
            });
        },
		
		goPersonalData: function () {
			uni.navigateTo({
			    url: '/agreement/pages/personalInfo/personalInfo'
			});
		},

        //安全防护
        goSafetyProtection: function () {
			uni.navigateTo({
			    url: '/agreement/pages/safetyProtection/safetyProtection'
			});
		},

        //退出登录
        Logout: function () {
			const that = this
            uni.showModal({
                title: '提示',
                content: '确定退出登录？',
				confirmColor: that.objColor2.textColor,   
                success: function (res) {   
                    if (res.confirm) {
						let type = '5';
						const systemInfo = uni.getSystemInfoSync();
						let uniPlatform = systemInfo.uniPlatform;
						let platform = systemInfo.platform;
						if(uniPlatform == 'mp-weixin') {
							type = '3'
						} else if(uniPlatform == 'web') {
							type = '5'
						} else if (platform == 'ios') {
							type = '0'
						} else if (platform == 'android') {
							type = '1'
						}
                        https_1.AppH5logout({
							type
						}).then(function (res) {
                            if (res.code == 0) {
                                uni.removeStorageSync('token');
								uni.removeStorageSync('memberType');
								uni.removeStorageSync('inviteType');
                                // uni.switchTab({
                                //     url: '/pages/index/index'
                                // });
                                
                                uni.reLaunch({
                                    url: '/pages/index/index'
                                });

                            }
                        });
                    }
                }
            });
        }
    }
};
</script>
<style lang="less">
@import url('./set.less');
</style>
